import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
// 导入字体图标
import './assets/fonts/iconfont.css'

import TreeTable from 'vue-table-with-tree-grid'
// 导入编辑器
import VueQuillEditor from 'vue-quill-editor'
// 导入富文本编辑器对应的样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

// axios网络请求
import axios from 'axios'
// 配置请求的根路径
axios.defaults.baseURL = 'https://www.liulongbin.top:8888/api/private/v1/'
// 请求拦截器（授权的 API ）
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.prototype.$http = axios

Vue.config.productionTip = false
// 注册为全局组件
Vue.component('tree-table', TreeTable)
// 注册编辑器为全局组件
Vue.use(VueQuillEditor)
// 注册时间过滤器全局组件
Vue.filter('dateFormat', function (originVal) {
  const dataTimer = new Date(originVal)

  // padStart(2, '0')不足两位时，用0补上
  const year = dataTimer.getFullYear()
  const month = (dataTimer.getMonth() + 1 + '').padStart(2, '0')
  const day = (dataTimer.getDate() + 1 + '').padStart(2, '0')
  const hour = (dataTimer.getHours() + 1 + '').padStart(2, '0')
  const minute = (dataTimer.getMinutes() + 1 + '').padStart(2, '0')
  const second = (dataTimer.getSeconds() + 1 + '').padStart(2, '0')
  return `${year}-${month}-${day} ${hour}:${minute}:${second}`
})
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
